<!--混凝土拌和站---动态监控--实时监控-->
<!--
 * @Author: 卡卡 1071780426@qq.com
 * @Date: 2022-12-02 13:13:25
 * @LastEditors: 贺楠 1071780426@qq.com
 * @LastEditTime: 2024-08-08 10:10:24
 * @FilePath: \backstage - 副本\src\views\aa.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="department" id="department">
    <!-- 左侧部门管理 -->
    <div class="structureTree" v-if="treelength">
      <div class="structureTree_title">
        <div>组织机构</div>
      </div>
      <tree
        :treeData="treeData"
        :checkData="checkData"
        name="pitchManage_treeCheck"
        nodeKey="fCompanyid"
        @getTreeInfo="handleNodeClick"
        :defaultProps="defaultProps"
      >
      </tree>
    </div>
    <!-- 右侧 -->
    <div class="department_right">
      <!-- 机构名称 -->
      <el-breadcrumb :title="showName"></el-breadcrumb>
      <!-- 顶部导航栏 -->
      <div class="mechanism_nav">
        <!-- 左侧 -->
        <div class="mechanism_nav_left" style="width: 100%">
          <vDatePicker
            :defaultDate="value2"
            @selectPickDate="selectTime"
            width="215px !important"
          >
          </vDatePicker>
          <div class="selectCondition">
            <el-select
              v-model="getList.fConstructionhorizon"
              placeholder="施工层位"
              @change="yj_searchForm(getList)"
            >
              <el-option
                v-for="v in sgcDataList"
                :key="v.fItemName"
                :label="v.fItemName"
                :value="v.fItemValue"
              >
              </el-option>
            </el-select>
          </div>

          <el-select
            class="selectBhz"
            style="width: 160px"
            v-model="getList.fMixturetype"
            placeholder="沥青混合料类型"
            @change="yj_searchForm(getList)"
          >
            <el-option
              v-for="v in liqhDataList"
              :key="v.fItemName"
              :label="v.fItemName"
              :value="v.fItemValue"
            >
            </el-option>
          </el-select>
        </div>
        <!-- 顶部按钮 -->
        <div class="print" style="display: flex; justify-content: flex-end">
          <el-button
            type="primary"
            icon="el-icon-refresh"
            size="small"
            @click="yj_searchForm(getList)"
          >
          </el-button>

          <el-button
            type="primary"
            icon="el-icon-search"
            size="small"
            @click="yj_editForm(2)"
            >查看配方
          </el-button>

          <el-button
            type="primary"
            v-if="btnPowerShow"
            icon="el-icon-circle-plus-outline"
            size="small"
            @click="yj_editForm(0)"
          >
            新增配方
          </el-button>

          <el-button
            type="primary"
            v-if="btnPowerShow"
            icon="el-icon-edit"
            size="small"
            @click="yj_editForm(1)"
          >
            编辑配方
          </el-button>

          <el-button
            type="primary"
            v-if="btnPowerShow"
            icon="el-icon-edit"
            size="small"
            @click="yj_editForm(3)"
          >
            设置级配
          </el-button>

          <el-button
            type="primary"
            v-if="btnPowerShow"
            icon="el-icon-delete"
            size="small"
            @click="rowDelete()"
            >删除
          </el-button>
        </div>
      </div>
      <!-- 表格 -->
      <div class="text_table">
        <tableData
          :height="navigatepageNums > 1 ? 'calc(100% - 50px)' : '100%'"
          :config="table_config"
          :dataList="tableData"
          :loading="listLoading"
          @selection-change="selectionChange"
          @sort-change="sortChange"
          @click-change="rowChange"
          @openDialog="yj_viewForm"
          :page="getList.page"
          :pageSize="getList.pageSize"
        />
        <pagination
          :info="queryCriteriaData"
          v-if="navigatepageNums > 1"
          :treelength="treelength"
          :total="queryCriteriaData.total"
          :pageNum.sync="getList.page"
          :limit.sync="getList.pageSize"
          @pagination="yj_searchForm(getList)"
        />
      </div>
      <!--弹框 查看 -->
      <div class="Control-1 mechanism_dialogS mixProportion">
        <el-dialog
          :title="dialogTitle"
          :modal-append-to-body="false"
          v-dialogDrag
          :visible.sync="dialogEditVisible"
          v-loading="loadingEditDialog"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div class="jpbox"></div>
          <div
            class="dialogBody common"
            id="mixProportionBox"
            :style="{ height: '650px' }"
            style="overflow: hidden"
          >
            <el-collapse v-model="activeNames" @change="changeCollapse">
              <el-collapse-item name="0" v-if="SZJP == 0">
                <template slot="title">
                  <div class="baseTitle">基本信息</div>
                </template>
                <!-- mixproportionForm -->
                <div style="height: 180px" class="OilStoneRate">
                  <publicForm
                    :messAgeNum="1"
                    ref="publicForm"
                    lableWidth="75px"
                    :formObj="formObj"
                    :formData="formData"
                    :timestamp="formData.fStatus"
                    :fileList="fSourcefileList"
                    @delteFile="delteFile"
                    @selectChange="selectChange"
                  >
                  </publicForm>
                </div>
              </el-collapse-item>
              <el-collapse-item name="1" v-if="SZJP == 0">
                <template slot="title">
                  <div class="baseTitle">油石比</div>
                </template>
                <div style="height: 35px" class="OilStoneRate">
                  <publicForm
                    :messAgeNum="1"
                    ref="publicForm0"
                    lableWidth="75px"
                    :formObj="OilStoneRate"
                    :formData="formData"
                  >
                  </publicForm>
                </div>
              </el-collapse-item>
              <el-collapse-item name="2" v-if="SZJP == 0">
                <template slot="title">
                  <div class="baseTitle">温度</div>
                </template>
                <div style="height: 35px" class="OilStoneRate">
                  <publicForm
                    :messAgeNum="1"
                    ref="publicForm1"
                    lableWidth="75px"
                    :formObj="temperature"
                    :formData="formData"
                  >
                  </publicForm>
                </div>
              </el-collapse-item>
              <el-collapse-item name="3" v-if="SZJP == 0">
                <template slot="title">
                  <div class="baseTitle">时长</div>
                </template>
                <div style="height: 35px" class="OilStoneRate">
                  <publicForm
                    :messAgeNum="1"
                    ref="publicForm1"
                    lableWidth="75px"
                    :formObj="mixingTime"
                    :formData="formData"
                  >
                  </publicForm>
                </div>
              </el-collapse-item>
              <el-collapse-item name="4" v-if="SZJP == 0">
                <template slot="title">
                  <div class="baseTitle">配合比</div>
                </template>
                <div style="height: 130px" class="OilStoneRate">
                  <publicForm
                    :messAgeNum="1"
                    ref="publicForm2"
                    lableWidth="85px"
                    :formObj="mixProportion"
                    :formData="formData"
                  >
                  </publicForm>
                </div>
              </el-collapse-item>
              <!-- 筛分实验数据 -->
              <el-collapse-item name="5" v-if="SZJP == 1">
                <template slot="title">
                  <div class="baseTitle">筛分实验数据</div>
                </template>

                <div style="height: 480px; width: 100%" class="fillableBox">
                  <div class="JpList">
                    <div
                      :class="{
                        JpSieveListBox,
                        JpSieveListBox2: iSJpSieveListBox == i,
                      }"
                      v-for="(v, i) in JpSieveList"
                      :key="i"
                      @click="JpSieveListFun(v, i)"
                    >
                      启用时间：{{ v.fCreatedates }}
                    </div>
                  </div>
                  <div class="JpDetails">
                    <tableData
                      :config="table_sieve"
                      :currentRow="false"
                      :dataList="sieveList"
                      :loading="listsieveLoading"
                      placeholderText=""
                      @inputValue="inputValue"
                      statusType="1"
                    />
                  </div>
                </div>
              </el-collapse-item>
            </el-collapse>
          </div>

          <div class="newlyAdded_btn_cnn" v-if="btnShow">
            <el-button type="primary" @click="yj_saveForm(0)" v-if="SZJP == 0">
              保存配方
            </el-button>
            <el-button type="primary" @click="yj_saveForm(1)" v-if="SZJP == 1">
              保存级配
            </el-button>
            <!-- <el-button type="warning" @click="close">关闭</el-button> -->
            <el-button type="warning" @click="dialogEditVisible = false">
              关闭
            </el-button>
          </div>
        </el-dialog>
      </div>
    </div>
  </div>
</template>
<script>
import vDatePicker from "@/components/public/v-DatePicker";
// import tree from "@/components/public/pitchManage_tree"; //左侧机构树
import tree from "@/components/stationProductionPage/pitchManage/tree"; //左侧机构树

import TableData from "@/components/public/el-tables"; //主页面列表
import Pagination from "@/components/public/el-pagination"; //主页面分页
import elBreadcrumb from "@/components/public/el-breadcrumb.vue"; //面包屑
import publicForm from "@/components/public/el-form.vue"; //弹框form
import formJs from "./regexDetail.js"; //新增弹框配置项


import {
  getUserCompanyTreeList, //左侧机构树接口
  getAsphaltRecipeLists, //沥青拌合站 基础设置 查询-配方管理列表页
  saveAsphaltRecipe, //沥青拌合站 基础设置 配方管理-配方保存接口
  delAsphaltRecipe, // 沥青拌合站 基础设置  删除-配方管理
  getAsphaltRecipeDetail, // 沥青拌合站 基础设置  查询-配方管理详情页
  getBaseDataitemDetailByItemCode, //字典项
  getAsphaltRecipeListByCompanyId, // 查询-沥青混合料类型下拉框
  getAsphaltRecipeSieveList, //级配列表
  saveAsphaltRecipeSieve, //级配保存
  getAsphaltRecipeSieveDetail, //级配详情
} from "@/api/request.js";

export default {
  name: "mixProportion",
  data() {
    return {
      name: "mixProportion", //按钮配置页面代号
      iSJpSieveListBox: 0,
      table_config: formJs.table_config, // 列表配置项
      table_sieve: formJs.sieveAperture, //级配设置
      activeNames: ["0", "1", "2", "3", "4"],
      navigatepageNums: null, //是否显示分页
      queryCriteriaData: {}, //分页
      value2: "", //主页面日期筛选绑定值
      tableData: [], //表格列表数据列表
      // sieveApertureData: formJs.sieveApertureData,//级配设置
      highlightBd: true, //左侧机构树停留背景色
      treelength: false, //左侧树显示隐藏
      showName: "未选择公司",
      fId: null, //点击当前列表数据fId
      listLoading: false, //列表数据加载loading
      listsieveLoading: false, //级配设置
      loadingEditDialog: false, //弹框loading
      dialogEditVisible: false, //新增弹框是否显示
      sgcDataList: formJs.sgcDataList, //施工层位
      liqhDataList: [], //沥青混合料类型
      formData: {
        userId: "", // 当前登录用户id
        userName: "", // 当前登录用户名
        fCompanyid: "", // 当前标段id
        fCompanyname: "", // 当前标段公司name
        fId: "", // 配方fid
        fRecipenumber: "", // 配方编号
        fRecipename: "", // 配方名称
        fMixturetype: "", // 混合料类型
        fMixduration: "", //拌合时长
        fPitchnum: "", // 沥青标号
        fStandard: "", // 执行标准
        fSurfacecourse: "", // 施工部位
        fStartdates: "", // 启用时间
        fRecipedescription: "", // 描述
        fStatus: "", // 配方附件
        fAsphaltaggregateratiogoalvalue: "", // 油石比目标值
        fAsphaltaggregateratioupper: "", // 油石比上限
        fAsphaltaggregateratiolower: "", // 油石比下限
        fTemperatureupper: "", // 温度上限
        fTemperaturelower: "", // 温度下限
        fAggregate1value: "", // 骨料1目标值
        fAggregate2value: "", // 骨料2目标值
        fAggregate3value: "", // 骨料3目标值
        fAggregate4value: "", // 骨料4目标值
        fAggregate5value: "", // 骨料5目标值
        fAggregate6value: "", // 骨料6目标值
        fPowder1value: "", // 粉料1目标值
        fPowder2value: "", // 粉料2目标值
        fPowder3value: "", // 粉料总目标值
        fCementvalue: "",
        sieveList: [],
        recordfiles: [], // 删除文件id集合
      },
      sieveList: [], //级配列表数据
      formObj: formJs.formObj,
      OilStoneRate: formJs.OilStoneRate,
      temperature: formJs.temperature,
      mixingTime: formJs.mixingTime,
      mixProportion: formJs.mixProportion,
      // 列表给后端传参
      getList: {
        fCompanyid: "", // 施工标段id
        startDates: "", // 开始时间
        endDates: "", // 截至时间
        stationId: "", //拌合站
        machineId: "", //拌合机
        fConstructionhorizon: "", // 施工层位
        fMixturetype: "", //  沥青混合料类型
        warningLevel: "", // 预警等级
        fCloseoperation: "", //闭合状态
        page: 1, // 当前页码
        pageSize: 20, // 每页显示条数
      },
      fSourcefileList: [],

      companyTree: "", //所有数据
      treeData: [], //左侧树状图数据
      // 左侧机构树
      defaultProps: {
        children: "children",
        label: "fShortname",
      },
      checkData: [], //树状图默认选中id
      userInfo: {}, //登录用户
      treeText: {
        //树状图参数
        companyId: null,
        userId: null,
        text: null,
      },
      dialogTitle: "查看",
      commonData: {},
      btnShow: true, //保存按钮是否显示
      publicTable: true, //新增配方表
      rowInfo: null,
      btnPowerShow: true,

      asphaltNoList: null, //字典温度查询
      SZJP: "", //控制显示弹框内容
      JpSieveList: [], //级配时间列表
    };
  },
  components: {
    vDatePicker, //时间选择器
    tree, //左侧组织机构数
    TableData, //主页面列表
    elBreadcrumb, //面包屑
    Pagination, //分页
    publicForm,
    // commonPage
  },
  mounted() {
    // this.table_config.operation.cols = [
    //     {
    //         label: "查看",
    //         prop: 'F_CloseOperations',
    //         type: 'primary',
    //         handleRow: this.handleRow
    //     }

    // ]
    this.userInfo = JSON.parse(sessionStorage.getItem("yjSmart-userInfo"));
    console.log("userInfo", this.userInfo);
    this.formObj[2].options = [];
    this.formObj[4].options = [];
    this.dictionaryItem("mixType", 0);
    this.dictionaryItem("asphaltNo", 1);

    if (JSON.parse(sessionStorage.getItem("yjSmart-pitchManage_getLists"))) {
      this.getList = JSON.parse(sessionStorage.getItem("yjSmart-pitchManage_getLists"));
    }
    if (JSON.parse(sessionStorage.getItem("yjSmart-pitchManage_treeCheck"))) {
      var id = JSON.parse(sessionStorage.getItem("yjSmart-pitchManage_treeCheck"));

      if (id.fNature == "总监办") {
        this.btnPowerShow = false;
      } else {
        this.btnPowerShow = true;
      }
      this.checkData = [id.fCompanyid];
    }
    this.getTree();
    this.btnRole(this.name);
    this.getDate();
  },
  methods: {
    btnRole(name) {
      // 按钮权限
      var btnList = [];
      var ModuleList = JSON.parse(sessionStorage.getItem("yjSmart-ModuleList"));
      if (ModuleList.length > 0) {
        ModuleList.map((item) => {
          if (item.fEncode == name) {
            btnList = item.modulebuttonList;
          }
        });
        var btnStr = [];
        btnList.map((item) => {
          btnStr.push(item.fEncode);
        });
        // this.yj_view = btnStr.includes("yj_view");
      } else {
        // this.yj_view = true;
      }
    },

    changeCollapse(e) {
      console.log(this.activeNames, e);
      return e;
    },
    // 点击当前行
    rowChange(val) {
      this.rowInfo = val;
    },
    // 左侧树结构
    getTree() {
      this.treeText = {
        companyId: this.userInfo.companyId,
        userId: this.userInfo.userId,
        text: "3", // 0其他  1 砼拌合站 2水稳 3沥青
      };
      getUserCompanyTreeList(this.treeText)
        .then((res) => {
          if (res.errcode == 0) {
            var companyTree = res.data.userCompanyTreeList;
            this.treeData = this.commonJs.tranListToTreeData(companyTree);
            if (this.treeData[0].children == undefined) {
              this.treelength = false; //左侧组织机构是否显示
            } else {
              this.treelength = true;
            }
            if (this.checkData[0]) {
              this.showName = JSON.parse(
                sessionStorage.getItem("yjSmart-pitchManage_treeCheck")
              ).fShortname;
              this.getList.fCompanyid = this.checkData[0];
            } else {
              this.checkData[0] = this.treeData[0].fCompanyid;
              this.showName = this.treeData[0].fShortname; //当前点击组织机构名称
              this.getList.fCompanyid = this.treeData[0].fCompanyid; //当前点击组织机构ID
            }
            this.getAsphaltRecipeListByCompanyId(this.getList.fCompanyid);
            this.yj_searchForm(this.getList); // 调用主页面列表接口
          } else {
            this.$message.error("获取组织机构失败", res.msg);
            return false;
          }
        })
        .catch(() => {
          return false;
        });
    },
    // 点击左侧机构树
    handleNodeClick(data) {
      this.showName = data.fShortname; //顶部显示机构名
      this.rowInfo = null;
      if (data.fNature == "总监办") {
        this.btnPowerShow = false;
      } else {
        this.btnPowerShow = true;
      }
      if (JSON.parse(sessionStorage.getItem("yjSmart-pitchManage_getLists"))) {
        this.getList = JSON.parse(
          sessionStorage.getItem("yjSmart-pitchManage_getLists")
        );
        this.getList.fCompanyid = data.fCompanyid;

        this.value2 = [this.getList.startDates, this.getList.endDates];
      } else {
        this.getList.fCompanyid = data.fCompanyid;
        this.getList.startDates = this.common.getDay(-6) + " " + "00:00:00"; // 开始时间
        this.getList.endDates = this.common.getDay(0) + " " + "23:59:59"; // 截至时间
        this.getList.fConstructionhorizon = ""; // 施工层位
        this.getList.fMixturetype = ""; //  沥青混合料类型
        this.getList.warningLevel = ""; // 预警等级
        this.getList.fCloseoperation = ""; // 闭合状态
        this.value2 = [
          this.common.getDay(-6) + " " + "00:00:00",
          this.common.getDay(0) + " " + "23:59:59",
        ];
      }
      this.getList.stationId = "";
      this.getList.machineId = "";
      this.getList.page = 1;
      this.getAsphaltRecipeListByCompanyId(this.getList.fCompanyid);

      this.yj_searchForm(this.getList);
    },
    // 新增编辑查看弹框
    yj_editForm(status) {
      if (status == 0) {
        //新增
        this.SZJP = "0";
        this.dialogTitle = "新增配方";
        this.userInfo = JSON.parse(sessionStorage.getItem("yjSmart-userInfo"));

        this.formData = {
          userId: this.userInfo.userId, // 当前登录用户id
          userName: this.userInfo.realName, // 当前登录用户名
          fCompanyid: this.getList.fCompanyid, // 当前登录用户公司id
          fCompanyname: this.showName, // 当前登录用户公司name
          fId: "", // 配方fid
          fRecipenumber: "", // 配方编号
          fRecipename: "", // 配方名称
          fMixturetype: "", // 混合料类型
          fMixduration: "", //拌合时长
          fPitchnum: "", // 沥青标号
          fStandard: "", // 执行标准
          fSurfacecourse: "", // 施工部位
          fStartdates: this.common.getDay(0) + " " + this.common.getDays(), // 启用时间
          fRecipedescription: "", // 描述
          fStatus: "", // 配方附件
          fAsphaltaggregateratiogoalvalue: "", // 油石比目标值
          fAsphaltaggregateratioupper: "", // 油石比上限
          fAsphaltaggregateratiolower: "", // 油石比下限
          fTemperatureupper: "", // 温度上限
          fTemperaturelower: "", // 温度下限
          fAggregate1value: "", // 骨料1目标值
          fAggregate2value: "", // 骨料2目标值
          fAggregate3value: "", // 骨料3目标值
          fAggregate4value: "", // 骨料4目标值
          fAggregate5value: "", // 骨料5目标值
          fAggregate6value: "", // 骨料6目标值
          fPowder1value: "", // 粉料1目标值
          fPowder2value: "", // 粉料2目标值
          fPowder3value: "", // 粉料总目标值
          fCementvalue: "",
          sieveList: [],
          recordfiles: [], // 删除文件id集合
        };
        this.fSourcefileList = [];
        getAsphaltRecipeDetail({ fId: "" }).then((res) => {
          if (res.errcode == 0) {
            this.formData = res.data.asphaltRecipe;
            this.formData.fStatus = res.data.asphaltRecipe.fStatus;
            this.formData.fMixturetype = res.data.asphaltRecipe.fMixturetype;
          } else {
            this.$message.error("获取详情接口报错", res.msg);
          }
        });

        this.formObj.map((item) => {
          //基本信息
          item.disabled = false;
          item.uploadSelect = true; //上传附件按钮是否显示
          // item.rules[0].required = true;
        });
        this.OilStoneRate.map((item) => {
          //油石比
          item.disabled = false;
          // item.rules[0].required = true;
        });
        this.temperature.map((item) => {
          //温度
          item.disabled = false;
          // item.rules[0].required = true;
        });
        this.mixProportion.map((item) => {
          //配合比
          item.disabled = false;
          // item.rules[0].required = true;
        });

        this.mixingTime.map((item) => {
          //拌合时长
          item.disabled = false;
          // item.rules[0].required = true;
        });

        this.table_sieve.thead.map((item, index) => {
          if (index != 0) {
            item.edit = true;
          }
        });
        this.dialogEditVisible = true;
        this.btnShow = true; //新增时按钮显示
        // this.loadingEditDialog = true
      } else if (status == 1) {
        //编辑
        this.dialogTitle = "编辑配方";
        this.SZJP = "0";
        this.btnShow = true; //编辑时按钮显示

        this.formObj.map((item) => {
          item.disabled = false;
          item.uploadSelect = true; //上传附件按钮是否显示
          // item.rules[0].required = true
        });
        this.OilStoneRate.map((item) => {
          //油石比
          item.disabled = false;
          // item.rules[0].required = true
        });
        this.temperature.map((item) => {
          //温度
          item.disabled = false;
          // item.rules[0].required = true
        });
        this.mixProportion.map((item) => {
          //配合比
          item.disabled = false;
        });
        this.mixingTime.map((item) => {
          //拌合时长
          item.disabled = false;
          // item.rules[0].required = true;
        });
        this.table_sieve.thead.map((item, index) => {
          if (index != 0) {
            item.edit = true;
          }
        });

        this.yj_viewForm();
      } else if (status == 2) {
        this.SZJP = "0";
        this.dialogTitle = "查看配方";
        this.btnShow = false; //编辑时按钮显示

        this.formObj.map((item) => {
          item.disabled = true;
          item.uploadSelect = false; //上传附件按钮是否显示
          // item.rules[0].required = false;
        });
        this.OilStoneRate.map((item) => {
          //油石比
          item.disabled = true;
          // item.rules[0].required = false;
        });
        this.temperature.map((item) => {
          //温度
          item.disabled = true;
          // item.rules[0].required = false;
        });
        this.mixProportion.map((item) => {
          //配合比
          item.disabled = true;
          // item.rules[0].required = false;
        });
        this.mixingTime.map((item) => {
          //拌合时长
          item.disabled = true;
          // item.rules[0].required = false;
        });

        this.table_sieve.thead.map((item, index) => {
          if (index != 0) {
            item.edit = false;
          }
        });
        this.yj_viewForm();
      } else if (status == 3) {
        //编辑
        this.dialogTitle = "设置级配";
        this.SZJP = "1";
        this.btnShow = true; //编辑时按钮显示
        // this.formObj.map((item) => {
        //   item.disabled = false;
        //   item.uploadSelect = true; //上传附件按钮是否显示
        // });
        // this.OilStoneRate.map((item) => {
        //   //油石比
        //   item.disabled = false;
        //   // item.rules[0].required = true
        // });
        // this.temperature.map((item) => {
        //   //温度
        //   item.disabled = false;
        //   // item.rules[0].required = true
        // });
        // this.mixProportion.map((item) => {
        //   //配合比
        //   item.disabled = false;
        // });
        // this.table_sieve.thead.map((item, index) => {
        //   if (index != 0) {
        //     item.edit = true;
        //   }
        // });
        this.activeNames = ["0", "1", "2", "3", "4", "5"];
        this.getJpList();
      }
    },
    // 级配列表
    getJpList() {
      var row = this.rowInfo;
      if (row != null) {
        var id = row.fId;
        this.fId = row.fId;
        this.dialogEditVisible = true;
        this.loadingEditDialog = true;
        getAsphaltRecipeSieveList({ fId: id })
          .then((res) => {
            if (res.errcode == 0) {
              this.loadingEditDialog = false;
              this.JpSieveList = res.data.sieveList;
              console.log("JpSieveList", this.JpSieveList);
              this.getJpDetails(
                res.data.sieveList[0].fCreatedates,
                res.data.sieveList[0].fParentid
              );
              console.log("级配列表", res);
            } else {
              this.$message.error("级配列表接口报错", res.msg);
            }
          })
          .catch(() => {
            console.log("级配列表接口报错");
          });
      } else {
        return this.$message.error("请先选择需要查看的数据");
      }
    },
    JpSieveListFun(data, i) {
      this.iSJpSieveListBox = i;
      this.getJpDetails(data.fCreatedates, data.fParentid);
      // return i
    },
    // 级配详情
    getJpDetails(time, id) {
      this.loadingEditDialog = true;
      getAsphaltRecipeSieveDetail({
        fCreatedates: time, // 级配启用时间
        fParentid: id, // 配方id
      })
        .then((res) => {
          if (res.errcode == 0) {
            this.loadingEditDialog = false;
            console.log("级配详情", res);
            var datas = res.data.asphaltRecipeSieveDetail;
            datas.map((item) => {
              if (
                item.fSieveupper != null &&
                item.fSieveupper != "" &&
                item.fSievelower != null &&
                item.fSievelower != ""
              ) {
                item.fSievemiddle =
                  (item.fSieveupper - 0 + (item.fSievelower - 0)) / 2;
              } else {
                item.fSievemiddle = "";
              }
            });
            this.sieveList = datas;
          } else {
            this.$message.error("级配详情接口报错", res.msg);
          }
        })
        .catch(() => {
          console.log("级配详情接口报错");
        });
    },
    // 获取列表数据
    yj_searchForm(data) {
      this.listLoading = true;
      window.sessionStorage.setItem(
        "yjSmart-pitchManage_getLists",
        JSON.stringify(data)
      );
      this.tableData = [];
      getAsphaltRecipeLists(data)
        .then((res) => {
          if (res.errcode == 0) {
            var that = this;
            that.listLoading = false;
            that.tableData = res.data.pageInfo.list;
            this.queryCriteriaData = res.data.pageInfo; //分页信息
            this.navigatepageNums =
              this.queryCriteriaData.navigatepageNums.length;
          } else {
            this.$message.error(res.msg);
            return false;
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
    yj_viewForm() {
      var row = this.rowInfo;
      if (row != null) {
        var id = row.fId;
        this.fId = row.fId;
        this.dialogEditVisible = true;
        this.loadingEditDialog = true;
        getAsphaltRecipeDetail({ fId: id }).then((res) => {
          if (res.errcode == 0) {
            this.loadingEditDialog = false;
            this.formData = res.data.asphaltRecipe;
            (this.formData.recordfiles = []), // 删除文件id集合
              (this.formData.fCompanyid = this.getList.fCompanyid);
            this.formData.fCompanyname = this.showName;

            this.fSourcefileList = res.data.fileList; // 附件
          } else {
            this.$message.error("获取详情接口报错", res.msg);
          }
        });
      } else {
        return this.$message.error("请先选择需要查看的数据");
      }
    },
    yj_saveForm(num) {
      if (num == 0) {
        if (this.publicTable == true) {
          if (
            this.$refs.publicForm.submitForm() &&
            this.$refs.publicForm0.submitForm() &&
            this.$refs.publicForm1.submitForm() &&
            this.$refs.publicForm2.submitForm()
          ) {
            this.formData.fCompanyid = this.userInfo.companyId;
            this.formData.fCompanyname = this.userInfo.companyName;
            saveAsphaltRecipe(this.formData).then((res) => {
              if (res.errcode == 0) {
                this.yj_searchForm(this.getList);
                this.dialogEditVisible = false;
                this.$message.success("新增成功");
              } else {
                this.$message.error("新增失败", res.msg);
                console.log("接口报错");
              }
            });
          } else {
            this.$message.warning("请把信息填写完整！");
          }
        } else {
          console.log(123);
        }
      } else if (num == 1) {
        console.log("级配保存");
        var data = {
          userId: this.userInfo.userId, // 当前登录用户id
          userName: this.userInfo.realName, // 当前登录用户名
          fCompanyid: this.userInfo.companyId, // 当前登录用户公司id
          fCompanyname: this.userInfo.companyName, // 当前登录用户公司name
          fId: this.fId, // 配方fid
          sieveList: this.sieveList,
        };
        saveAsphaltRecipeSieve(data).then((res) => {
          if (res.errcode == 0) {
            this.yj_searchForm(this.getList);
            this.dialogEditVisible = false;
            this.$message.success("新增级配成功");
          } else {
            this.$message.error("新增级配失败", res.msg);
            console.log("保存级配接口报错");
          }
        });
      }
    },

    getAsphaltRecipeListByCompanyId(id) {
      var data = {
        fCompanyid: id,
      };
      this.liqhDataList = [];
      getAsphaltRecipeListByCompanyId(data)
        .then((res) => {
          if (res.errcode == 0) {
            var arr = res.data.asphaltRecipeList;
            this.liqhDataList = [
              {
                fItemName: "所有沥青混合料类型",
                fItemValue: "",
              },
            ];
            arr.map((item) => {
              this.liqhDataList.push({
                fItemName: item.fMixturetype,
                fItemValue: item.fMixturetype,
              });
            });
          } else {
            this.$message.error(res.msg);
            return false;
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },

    selectChange(value, index, prop) {
      // 下拉框改变
      console.log("index", index);
      let itemvalue = null;
      if (prop == "fPitchnum") {
        for (let index = 0; index < this.asphaltNoList.length; index++) {
          const element = this.asphaltNoList[index];
          if (value == element.fItemname) {
            itemvalue = element.fItemvalue.split("-");
          }
        }

        this.formData.fTemperatureupper = itemvalue[1];
        this.formData.fTemperaturelower = itemvalue[0];
      }
    },
    // 获取字典项
    dictionaryItem(id, num) {
      getBaseDataitemDetailByItemCode({ fItemcode: id })
        .then((res) => {
          if (res.errcode == 0) {
            if (num == 1) {
              this.asphaltNoList = res.data.baseDataitemdetailList;
            }

            res.data.baseDataitemdetailList.map((item) => {
              if (num == 0) {
                this.formObj[2].options.push({
                  value: item.fItemname,
                  label: item.fItemname,
                });
              } else if (num == 1) {
                this.formObj[4].options.push({
                  value: item.fItemname,
                  label: item.fItemname,
                });
              }
            });
          } else {
            this.$message.error("获取字典项", res.msg);
          }
        })
        .catch(() => {
          console.log("获取字典项失败");
        });
    },

    inputValue(val, table, label) {
      if (label == "fSieveupper" || label == "fSievelower") {
        table.map((item) => {
          if (
            item.fSieveupper != null &&
            item.fSieveupper != "" &&
            item.fSievelower != null &&
            item.fSievelower != ""
          ) {
            item.fSievemiddle =
              (item.fSieveupper - 0 + (item.fSievelower - 0)) / 2;
          } else {
            item.fSievemiddle = "";
          }
        });
      }
      this.sieveList = table;
    },

    rowDelete() {
      if (this.rowInfo != null) {
        this.listLoading = true;
        this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            delAsphaltRecipe({ fId: this.rowInfo.fId }).then((res) => {
              if (res.errcode == 0) {
                this.listLoading = false;
                this.yj_searchForm(this.getList);
                this.$message.success("删除成功");
              } else {
                this.$message.error("删除失败", res.msg);

                return false;
              }
            });
          })
          .catch(() => {
            this.listLoading = false;
            this.$message("取消删除");
          });
      } else {
        return this.$message.error("请先选择需要删除的数据");
      }
    },
    delteFile(file) {
      // console.log(file, this.fSourcefileList);
      for (let index = 0; index < this.fSourcefileList.length; index++) {
        if (file.uid == this.fSourcefileList[index].uid) {
          if (this.fSourcefileList[index].atta == undefined) {
            this.formData.recordfiles.push({
              fId: this.fSourcefileList[index].fId,
            });
          } else {
            this.formData.recordfiles.push({
              fId: this.fSourcefileList[index].atta.fId,
            });
          }
          this.fSourcefileList.splice(index, 1);
        }
      }
    },
    // 公共弹框是否显示
    loadingShow(e) {
      this.loadingEditDialog = e;
    },
    // 时间间隔
    // selectTime(e) {
    //     this.getList.startDates = e[0] + " " + "00:00:00"// 开始时间
    //     this.getList.endDates = e[1] + " " + "23:59:59"// 截至时间
    //     this.yj_searchForm(this.getList);
    // },
    selectTime(e) {
      if (e[0] != "" && e[1] != "") {
        this.getList.startDates = e[0] + " " + "00:00:00"; // 开始时间
        this.getList.endDates = e[1] + " " + "23:59:59"; // 截至时间
      } else {
        this.getList.startDates = ""; // 开始时间
        this.getList.endDates = ""; // 截至时间
      }
      this.yj_searchForm(this.getList);
    },
    getDate() {
      if (JSON.parse(sessionStorage.getItem("yjSmart-pitchManage_getLists"))) {
        this.getList = JSON.parse(
          sessionStorage.getItem("yjSmart-pitchManage_getLists")
        );
        this.getList.page = 1;
        this.value2 = [this.getList.startDates, this.getList.endDates];
      } else {
        this.getList.startDates = this.common.getDay(-6) + " " + "00:00:00"; // 开始时间
        this.getList.endDates = this.common.getDay(0) + " " + "23:59:59"; // 截至时间
        this.value2 = [
          this.common.getDay(-6) + " " + "00:00:00",
          this.common.getDay(0) + " " + "23:59:59",
        ];
      }
    },
    selectionChange() {},
    // 排序方法
    sortChange() {},
  },
};
</script>
  
<style scoped lang="less">
.printTables {
  background: #fff;
  display: flex;
  justify-content: end;
  padding: 5px;
  margin-top: 10px;
}

.jpbox {
  height: 100%;
}

.dialogBody {
  padding: 3px 20px;
  height: 80%;
  // overflow-y: auto;
  // display: flex;
  // flex-direction: column;
}

.baseTitle {
  /* border: 1px solid #0c204d; */
  border-bottom: 1px solid #0c204d;
  width: 100%;
  height: 30px;
  line-height: 30px;
  position: relative;
  padding-left: 15px;
}

.baseTitle::after {
  display: block;
  content: "";
  height: 30px;
  width: 5px;
  position: absolute;
  left: 0;
  top: 0;
  background: #0c204d;
}

.mixProportion /deep/ .el-form-item__content {
  margin-left: 180px !important;
}
.fillableBox {
  display: flex;
}
.JpList {
  width: 250px;
  height: 100%;
  border: 1px solid #ccc;
  overflow-y: auto;
  div {
    width: 100%;
    height: 20px;
    line-height: 20px;
    border-bottom: 1px solid #ccc;
    text-align: center;
    background: #fff;
    color: #000;
  }
  .JpSieveListBox {
    width: 100%;
    height: 20px;
    line-height: 20px;
    border-bottom: 1px solid #ccc;
    text-align: center;
    background: #fff;
    color: #000;
  }
  .JpSieveListBox2 {
    background: #1559ba;
    color: #fff;
  }
}
.JpDetails {
  width: calc(100% - 250px);
  height: 100%;
}
.fillableBox /deep/ .el-table .cell {
  padding: 0 !important;
}

.fillableBox /deep/ .el-input__inner {
  border: none;
  height: 31px !important;
  padding: 0 !important;
  text-align: center;
}

.mixproportionForm /deep/ .el-select {
  width: 100% !important;
}

.OilStoneRate /deep/ .el-select {
  width: 100% !important;
}

.OilStoneRate /deep/ .el-form-item__content {
  margin-left: 95px !important;
}

#mixProportionBox /deep/ .el-collapse-item__content {
  padding-bottom: 10px !important;
}

.OilStoneRate /deep/ .el-col-8 {
  height: 30px;
  width: 33.3%;
}

.selectCondition /deep/ .el-select {
  width: 100px !important;
}

.selectCondition /deep/ .el-input__inner {
  width: 100px !important;
  height: 30px !important;
}
</style>